import { useNavigate, useLocation } from 'react-router-dom'
import { useEffect } from 'react'
// 路由重定向
const useRedirect = (path: string, newPath: string) => {
    const navigate = useNavigate()
    const location = useLocation()
    useEffect(() => {
        if (location.pathname === path) {
            navigate(newPath)
        }
    }, [location.pathname]);
}

export default useRedirect